package com.sumainfor.pc.market.controller;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.dao.HousingInfoStateMapper;
import com.sumainfor.pc.market.service.HousingInfoStateServiceImpl;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 待审核配置房源(错误)
 * <p>
 *
 * @author: zhoucong
 * @create: 2019-04-13 19:50
 **/
@Controller
@RequestMapping("/key/HousingInfoState")
public class HousingInfoStateController {

    @Autowired
    HousingInfoStateServiceImpl housingInfoStateService;

    /**
    * <p>
    * 待审核配置房源
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @GetMapping("/getAuditHousingCount")
    public JsonResult getAuditHousingCount(){
        JsonResult result = new JsonResult();
        Map<String,Object> map = new HashMap<>();
        Integer InspectStateCount = housingInfoStateService.getAuditHousingCount();
        map.put("InspectStateCount",InspectStateCount);
        return result.put(map);
    }

    /**
    * <p>
    *  待审核配置房源
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @ResponseBody
    @GetMapping("/getAuditHousing")
    public JsonResult getAuditHousing(@RequestParam Map<String,Object> params,Pager pager){

        pager.setPageno(Integer.parseInt(params.get("pageno").toString()));
        pager.setPagesize(Integer.parseInt(params.get("pagesize").toString()));
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout = housingInfoStateService.getAuditHousingCount();
        if (cout == 0) {
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,0);
        }
        List<Map<String,Object>> getAuditHousing =housingInfoStateService.getAuditHousing(params);

        return pageUtils.getJsonResult(getAuditHousing, params, cout);

    }
}
